#include "startsence.h"
#include <QPushButton>
#include <QVBoxLayout>
#include <QFrame>
#include <QPainter>
#include <QSpacerItem>


StartSence::StartSence(QWidget *parent, int frame_size, int window_width, int window_height)
    : QWidget(parent)
    , f_size(frame_size)
    , w_width(window_width)
    , w_heigth(window_height)

{


   this->setObjectName("mainMenu");

   this->setStyleSheet(

                "QPushButton {"
                  "    background-color: #FF4136;"  // 红色背景
                  "    color: black;"               // 黑色文字
                  "    font : 30px;"
                  "    border-radius: 5px;"         // 圆角
                  "    border: 5px solid black;"
                  "    padding: 8px 16px;"          // 内边距

                  "}"

                  "QPushButton:hover {"
                  "    background-color: #E73A30;"  // 悬停时颜色变深
                  "}"

                  "QPushButton:pressed {"
                  "    background-color: #CC332A;"  // 按下时颜色更深
                  "}");

    QPushButton* start = new QPushButton("开始游戏", this);
    QPushButton* quit = new QPushButton("退出游戏", this);

    start->setGeometry(380, 320, 200, 100);
    quit->setGeometry(380, 440, 200, 100);

    // 进入游戏
    connect(start, &QPushButton::clicked, this, &StartSence::handlePlayGame);
    // 关闭程序
    connect(quit, &QPushButton::clicked, this, &StartSence::handleExit);
}

void StartSence::paintEvent(QPaintEvent *event)
{
    (void)(event);
    QPainter painter(this);

    QPixmap pixmap(":/main_background.png");
    painter.drawPixmap(f_size, f_size, w_width, w_heigth, pixmap);

}

void StartSence::handleExit()
{
    emit exit();
}

void StartSence::handlePlayGame()
{
    emit play();
}
